﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TPA.DataAccess
{
    public class Filter
    {
        private List<string> m_values;
        public Filter()
        {
            m_values = new List<string>();
        }
        public FilterConnectorType Connector
        {
            get;
            set;
        }
        public string PropertyName
        {
            get;
            set;
        }
        public List<string> Values
        {
            get { return m_values; }
            set { m_values = value; }
        }
        public string ValuesString
        {
            get { return concatenate(Values); }
        }
        string concatenate(List<string> list)
        {
            string retval = "";
            foreach (string s in list)
            {
                if (retval == "")
                {
                    retval += s;
                }
                else
                {
                    retval += "," + s;
                }
            }
            return "{" + retval + "}";
        }
        public override string ToString()
        {
            return string.Format("{0}:{1}.{2}", this.PropertyName, concatenate(this.Values), this.Connector.ToString());
        }
    }

    public enum FilterConnectorType { AND,OR}
}
